// pages/detail-video/index.js
import {
    getMVURL,
    getMVDetail,
    getRelatedVideo
} from '../../service/api_video'
Page({

    /**
     * 页面的初始数据
     */
    data: {
        mvURLInfo: {},
        mvDetail: {},
        relatedVideos: [],
        danmuList: [{
            text: "弹幕1",
            color: "#f40",
            time: 2
        }, {
            text: "弹幕2",
            color: "##ff00ff",
            time: 4
        }]
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        //拿到传递过来的视频id
        const id = options.id
        this.getPageDetail(id)
    },
    /**
     * 获取页面数据
     * @param {number} id 
     */
    getPageDetail: function (id) {
        getMVURL(id).then(res => {
            this.setData({
                mvURLInfo: res.data
            })
        })
        getMVDetail(id).then(res => {
            this.setData({
                mvDetail: res.data
            })
        })
        getRelatedVideo(id).then(res => {
            this.setData({
                relatedVideos: res.data
            })
        })
    }

})